import { getToken } from '../services/token';

const websocket = (callback) => {
  const socketUrl = 'ws://202.120.40.87:42163/websocket';
  const socket = new WebSocket(socketUrl);
  socket.onopen = () => {
    socket.send(getToken());
  };
  socket.onmessage = () => callback();
};

export default websocket;
